#!/usr/bin/perl -w
#
# Copyright (C) 2005 Taylor L. Riché <riche@cs.utexas.edu>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# 	$Id: lpkg.in 273 2005-10-06 18:29:23Z richetl $	
#

$includedir = "#INCLUDE#";

for($i = 0; $i < scalar @ARGV; $i += 1) {
    @args = ("g++", "-fPIC", "-I$includedir", "-g", "-Wall", 
	     "-O0", "-c", "llt_$ARGV[$i].cc");
    print "Compiling $ARGV[$i]\n";
    system(@args) == 0
	or die "Compile failed (@args): $?";
    $objects[$i] = "llt_$ARGV[$i].o";
}

$i -= 1;

@args = ("g++", "-fPIC", "-I$includedir", "-g", "-Wall", 
	 "-O0", "-c", "llt_$ARGV[$i]_gen.cc");
print "Compiling $ARGV[$i]_gen\n";
system(@args) == 0
    or die "Compile failed (@args): $?";
$objects[$i+1] = "llt_$ARGV[$i]_gen.o";


@args = ("g++", "-shared", "-fPIC", "-o$ARGV[scalar @ARGV - 1].lapp");
$numArgs = scalar @args;
$numObjs = scalar @objects;
for($i = scalar @args; $i < $numArgs + $numObjs; $i += 1) {
    $args[$i] = $objects[$i - $numArgs];
}
print "Creating $ARGV[scalar @ARGV - 1].lapp\n";
system(@args) == 0
    or die "Linking failed (@args): $?";
exit(0);
